/***************************************************************
 *
 * Filename：TCPClient.h
 * Abstract：the design of TCP
 * version ：1.0
 *
 * Copyright (c) 2011 SCUT DT&P FY&XC
 *
***************************************************************/
#ifndef TCPCLIENT_H
#define TCPCLIENT_H

#include <QtGui>
#include <QtNetwork>
#include <QDebug>
#include <QTcpServer>
#include "FileReveWindow.h"
#include "ipmsg.h"

class TCPClient : public QObject
{
    Q_OBJECT
public:
    TCPClient(QHostAddress,QString,FileReveWindow*);
    void newConnect();  ////连接服务器
private:
    QTcpSocket *tcpClient;
    quint16 blockSize;
    QHostAddress UserAddr;
    FileReveWindow *FileW;

    qint64 TotalBytes;  //数据总大小
    qint64 bytesReceived;   //已经接收数据大小
    qint64 bytesToReceive;  //剩余数据大小
    qint64 fileNameSize;
    QString fileName;   //接收的文件名
    QFile *localFile;  //接收文件路径
    QByteArray inBlock; //数据缓冲区，即存放每次接收的数据

    QTime time;

public slots:
    void readMessage();  //发送文件大小等信息
    void displayError(QAbstractSocket::SocketError); //显示错误
};

#endif // TCPCLIENT_H
